package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.SurgicalInfoDTO;
import com.hksj.Intelligentmanagement.service.SurgicalInfoService;
import com.hksj.Intelligentmanagement.vo.SurgicalInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName SurgicalInfoController
 * @Description TODO
 * @Author @陈章
 * @Date 2023/3/31 10:58
 * @Version 1.0
 */
@Api(tags = "手术信息管理")
@RestController
@RequestMapping("/api/surgicalInfo")
public class SurgicalInfoController {

    @Autowired
    private SurgicalInfoService surgicalInfoService;

    /**
     * 查询所有手术信息
     *
     * @return
     */
    @ApiOperation(value = "查询所有手术信息 ")
    @GetMapping("selectAllSurgicalInfo")
    public Result selectAllSurgicalInfo(String time) {
        List<SurgicalInfoVo> surgicalInfoVo = surgicalInfoService.selectAllSurgicalInfo(time);
        return Result.ok(surgicalInfoVo);
    }


    /**
     * 拟定排班预计时间
     *
     * @return
     */
    @ApiOperation(value = "拟定排班预计时间 ")
    @GetMapping("updateEstimateTime")
    public Result updateEstimateTime(String id, String startTime,String endTime) {
        surgicalInfoService.updateEstimateTime(id,startTime,endTime);
        return Result.ok();
    }


    /**
     * 新增手术信息
     *
     * @return
     */
    @ApiOperation(value = "新增手术信息 ")
    @PostMapping("addSurgicalInfo")
    public Result addSurgicalInfo(@RequestBody SurgicalInfoDTO dto) {
        surgicalInfoService.addSurgicalInfo(dto);
        return Result.ok();
    }

    /**
     * 删除手术信息
     *
     * @return
     */
    @ApiOperation(value = "删除手术信息 ")
    @GetMapping("delSurgicalInfo")
    public Result delSurgicalInfo(String id) {
        surgicalInfoService.delSurgicalInfo(id);
        return Result.ok();
    }

    /**
     * 更新手术信息
     *
     * @return
     */
    @ApiOperation(value = "更新手术信息 ")
    @PostMapping("updateSurgicalInfo")
    public Result updateSurgicalInfo(@RequestBody SurgicalInfoDTO dto) {
        surgicalInfoService.updateSurgicalInfo(dto);
        return Result.ok();
    }
}
